package com.zbkj.front.controller.burying_point;

import com.zbkj.common.model.burying_point.UserClickButton;
import com.zbkj.common.request.UserClickButtonRequest;
import com.zbkj.common.result.CommonResult;
import com.zbkj.service.service.burying_point.UserClickButtonService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Date;



@Slf4j
@RestController
@RequestMapping("api/user-click-button")
@Api(tags = "用户点击按钮表") //配合swagger使用

public class UserClickButtonController {

    @Autowired
    private UserClickButtonService userClickButtonService;


    /**
     * 新增用户点击按钮表
     *
     * @param userClickButtonRequest 新增参数
     * @author keNan
     * @since 2025-04-28
     */
    @ApiOperation(value = "新增")
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    public CommonResult<String> save(@RequestBody @Validated UserClickButtonRequest userClickButtonRequest) {
        UserClickButton userClickButton = new UserClickButton()
                .setCreateTime(new Date());
        BeanUtils.copyProperties(userClickButtonRequest, userClickButton);

        if (userClickButtonService.save(userClickButton)) {
            return CommonResult.success();
        } else {
            return CommonResult.failed();
        }
    }


}



